using IQIGame.Onigao.Framework;

namespace IQIGame.Onigao.GamePlay
{
    public class LevelAnimationComponent : EntityAnimationComponent
    {
        //覆盖基础实体
        public LevelPlayRealityEntity entity => _entity as LevelPlayRealityEntity;

        public void PlayAttack()
        {
            if (animator == null)
            {
                return;
            }
            animator.CrossFade(AnimationConst.Name_Attact, 0);
        }

        public void PlayJumpStart(float crocssTime)
        {
            if (animator == null)
            {
                return;
            }
            animator.CrossFade(AnimationConst.Name_JumpStart, crocssTime);
        }

        public void PlayJumpStartTrigger()
        {
            if (animator == null)
            {
                return;
            }
            animator.SetTrigger(AnimationConst.Param_JumpStart);
        }

        public void TriggerJumpEnd()
        {
            if (animator == null)
            {
                return;
            }
            animator.SetTrigger(AnimationConst.Param_JumpEnd);
        }

        public void PlayStateOpenClose(bool isOpen)
        {
            if (animator == null)
            {
                return;
            }
            if (isOpen)
            {
                if (animator.HasState(0, AnimationConst.Name_State_Open1))
                {
                    animator.CrossFade(AnimationConst.Name_State_Open1, AnimationConst.CommonTransitionDuration);
                }
                else
                {
                    LogGame.LogWarning("未找到开门动画：State_Open1");
                }
            }
            else
            {
                if (animator.HasState(0, AnimationConst.Name_State_Close2))
                {
                    animator.CrossFade(AnimationConst.Name_State_Close2, AnimationConst.CommonTransitionDuration);
                }
                else
                {
                    LogGame.LogWarning("未找到关门动画：State_Close2");
                }
            }
        }

        public void PlayAlert()
        {
            if (animator == null)
            {
                return;
            }
            animator.CrossFade(AnimationConst.Name_Warn, 0);
        }

        public void PlayHit()
        {
            if (animator == null)
            {
                return;
            }
            animator.CrossFade(AnimationConst.Name_Hit, 0);
        }

        #region ObjectPool

        public override uint MaxStore => 50;

        
        #endregion

    }
}